package com.lushuai.jiubeidanci;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;

public class LaunchActivity extends AppCompatActivity {
    private static final long SPLASH_DELAY = 2000; // 启动页显示时间

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launch);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                checkLoginStatus();
            }
        }, SPLASH_DELAY);
    }

    private void checkLoginStatus() {
        SharedPreferences sp = getSharedPreferences("user_info", MODE_PRIVATE);
        long userId = sp.getLong("user_id", -1);

        Intent intent;
        if (userId != -1) {
            // 已登录，直接进入主界面
            intent = new Intent(this, MainActivity.class);
        } else {
            // 未登录，进入登录界面
            intent = new Intent(this, LoginActivity.class);
        }
        startActivity(intent);
        finish();
    }
} 